package br.com.SGF.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


@Entity 
@Table(name= "cadastro_usuario")
@NamedQueries({
	@NamedQuery(name = "Usuario.listar", query = "SELECT usuario FROM UsuarioDomain usuario"),
	@NamedQuery(name = "Usuario.autenticar", query = "SELECT usuario FROM UsuarioDomain usuario WHERE usuario.nome =:nome AND usuario.senha = :senha"),
	@NamedQuery(name = "Usuario.obterCodigo", query = "SELECT usuario  FROM UsuarioDomain usuario where codUsuario = :codigo") })
public class UsuarioDomain {

	@Id
	@GeneratedValue (strategy = GenerationType.AUTO)
	@Column (name="usu_id")
	private int codUsu;
	
	@Column(name = "usu_nome", length = 50, nullable = false)
	private String nome;
	
	@Column (name="usu_senha", length = 45, nullable = false)
	private String senha;
	
	@Column (name="usu_descricao", length = 50, nullable = false)
	private String descricao;
	
	@Column (name="usu_inativo", columnDefinition="tinyint default false")
	private boolean inativo;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "usu_car_id", referencedColumnName = "car_id")
	private CargoDomain cargo;
	
	//private boolean inativo;
	
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public String getSenha() {
		return senha;
	}
	public void setSenha(String senha) {
		this.senha = senha;
	}
	public String getDescricao() {
		return descricao;
	}
	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}
	public int getCodUsu(int i) {
		return codUsu;
	}
	public void setCodUsu(int codUsu) {
		this.codUsu = codUsu;
	}
	public CargoDomain getCargo() {
		return cargo;
	}
	public void setCargo(CargoDomain cargo) {
		this.cargo = cargo;
	}
	public boolean isInativo() {
		return inativo;
	}
	public void setInativo(boolean inativo) {
		this.inativo = inativo;
	}
	@Override
	public String toString() {
		return "UsuarioDomain [codUsu=" + codUsu + ", nome=" + nome
				+ ", senha=" + senha + ", descricao=" + descricao
				+ ", inativo=" + inativo + ", cargo=" + cargo + "]";
	}
	
	
	
	

	
	
	
}
